package org.blogsomy.jaas;

import java.security.Principal;

final public class BlogsomyRole implements Principal {

	private final String name;

	
	public BlogsomyRole(String username) {
		this.name = username;
	}

	@Override
	public boolean equals(final Object obj) {
		if (this == obj) {
			return true;
		}
		
		if (!(obj instanceof BlogsomyRole)) {
			return false;
		}
		
		BlogsomyRole principal = (BlogsomyRole) obj;
		
		return (name == null ? principal.getName() == null 
	 			  				 : name.equals(principal.getName()));
	}

	@Override
	public int hashCode() {
		return name.hashCode();
	}
	
	@Override
	public String getName() {
		return name;
	}
}
